﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Microsoft Corp." file="CreateStorageAccountCommand.cs">
//   All rights reserved. See License.txt in the project root for license information.
// </copyright>
// 
// --------------------------------------------------------------------------------------------------------------------
namespace AzureManagement.AzureCommands
{
    using System;

    using AzureManagement.AzureDataContracts;

    using Common;

    using RestClient;

    public class CreateStorageAccountCommand : AzureManagementCommand
    {
        private readonly CreateStorageServiceInput createStorageServiceInput;

        public CreateStorageAccountCommand(
            IAzureServiceContext serviceContext, CreateStorageServiceInput createStorageServiceInput)
            : base(serviceContext)
        {
            if (createStorageServiceInput == null)
            {
                throw new ArgumentNullException("createStorageServiceInput", "Storage account details must not be null.");
            }

            this.createStorageServiceInput = createStorageServiceInput;
        }

        protected override RequestContext GetRequestContext()
        {
            return this.CreatePostOperationRequestContext();
        }

        protected override string FormatPath(IAzureServiceContext azureServiceContext)
        {
            return string.Format("{0}/services/storageservices", azureServiceContext.SubscriptionId);
        }

        protected override string FormatBody()
        {
            return XmlHelper.Serialize(this.createStorageServiceInput);
        }
    }
}